<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Generator" content="ECSHOP v3.0.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="" />
<meta name="Description" content="" /> 
<title>用户中心_ECSHOP演示站 - Powered by ECShop</title>
<base href="__STATIC__/home/" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" href="animated_favicon.gif" type="image/gif" />
<link href="themes/default/style.css" rel="stylesheet" type="text/css" />
<body>
{include file="Public/header"}
<div class="clear0 "></div>
<div class="block box">
 <div id="ur_here">
  <div class="path"><div>当前位置: <a href=".">首页</a> <code>&gt;</code> 用户中心</div></div>  </div>
</div>
<div class="blank"></div>
<div class="usBox">
  <div class="usBox_2 clearfix">
   <div class="regtitle"></div>
    <form action="{:url('regist_do')}" method="post" name="formUser" onsubmit="return register();">
      <table width="100%"  border="0" align="left" cellpadding="5" cellspacing="3">
        <tr>
          <td width="13%" align="right">用户名</td>
          <td width="87%">
          <input name="username" type="text" size="25" id="username"  class="inputBg"/>
            <span id="s_username" style="color:#FF0000">*</span>
          </td>
        </tr>
        <tr>
          <td align="right">email</td>
          <td>
          <input name="email" type="text" size="25" id="email"   class="inputBg"/>
            <span id="s_email" style="color:#FF0000"> *</span>
          </td>
        </tr>
        <tr>
          <td align="right">性别</td>
          <td>
          <input name="sex" type="radio" checked size="25" value="1"/>
          <input name="sex" type="radio" size="25" value="0"/>
          </td>
        </tr>
        <tr>
          <td align="right">密码</td>
          <td>
          <input name="password" type="password" id="password" class="inputBg" style="width:179px;" />
            <span style="color:#FF0000" id="s_password"> *</span>
          </td>
        </tr>
        <tr>
          <td align="right">密码强度</td>
          <td>
            <table width="145" border="0" cellspacing="0" cellpadding="1">
              <tr align="center">
                <td width="33%" id="pwd_lower">弱</td>
                <td width="33%" id="pwd_middle">中</td>
                <td width="33%" id="pwd_high">强</td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td align="right">确认密码</td>
          <td>
          <input type="password" id="password1"  class="inputBg" style="width:179px;"/>
            <span style="color:#FF0000" id="s_password1"> *</span>
          </td>
        </tr>
			   <tr>
          <td align="right">手机<td>
          <input name="tell" id="tell" type="text" size="25" class="inputBg" />
          <span id="s_tell" style="color:#FF0000"> *</span>
          </td>
        </tr>
        <tr>
          <td align="right" >身份证号<td>
          <input name="number" id="number" type="text" size="25" class="inputBg" />
          <span id="s_number" style="color:#FF0000"> *</span>
          </td>
        </tr>
			<!--  <tr>
          <td align="right">密码提示问题</td>
          <td>
          <select name='sel_question'>
          	  <option value='0'>请选择密码提示问题</option>
          	  <option value="friend_birthday">我最好朋友的生日？</option>
              <option value="old_address">我儿时居住地的地址？</option>
              <option value="motto">我的座右铭是？</option>
              <option value="favorite_movie">我最喜爱的电影？</option>
              <option value="favorite_song">我最喜爱的歌曲？</option>
              <option value="favorite_food">我最喜爱的食物？</option>
              <option value="interest">我最大的爱好？</option>
              <option value="favorite_novel">我最喜欢的小说？</option>
              <option value="favorite_equipe">我最喜欢的运动队？</option>
          </select>
          </td>
        </tr>
        <tr>
          <td align="right" >密码问题答案</td>
          <td>
	             <input name="passwd_answer" type="text" size="25" class="inputBg" maxlengt='20'/>
          </td>
        </tr> -->
		    <tr>
          <td>&nbsp;</td>
          <td><label>
            <input type="checkbox" value="1" checked="checked" />
            我已看过并接受《<a href="article.php?cat_id=-1" style="color:blue" target="_blank">用户协议</a>》</label></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="left"><input type="submit" value="注册" id="submit">
          </td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td class="actionSub">
          <a href="{:url('Home/login/login')}">我已有账号，我要登录</a><br />
          <a href="user.php?act=get_password">您忘记密码了吗？</a>
          </td>
        </tr>
      </table>
    </form>
  </div>
</div>
<div class="blank"></div>
{include file='Public/footer'}<!-- 引入公共底部文件 -->
</body>
<script src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">

var msg =false;
var msg1 =false;
var msg2 =false;
var msg3 =false;
var msg4 =false;
var msg5 =false;

    //验证用户名
    $(document).on('blur','#username',function(){
      var username=$("#username").val();
      var obj = /^[a-z]{5,9}$/;
      if (username=="") {
        $("#s_username").html("<font color='red'>用户名不能为空</font>");
        return msg=false;
      }else{ 
        if(!obj.test(username)){
           $("#s_username").html("<font color='red'>用户名必须是5-9位且不能是数字</font>");
            return msg=false;
          }else{
                  $.ajax({
                    url:'{:url("regist_once")}',
                    data:{username,username},
                    type:"post",
                    dataType:"json",
                    success:function(res){
                      // alert(res)
                           if (res==3) {
                             $("#s_username").html("<font color='black'>√</font>");
                             var b=1;
                           }else{
                             $("#s_username").html("<font color='red'>用户名已存在</font>");
                             var b=2;
                          }
                    }
                  })
                  if (b =1) {
                    return msg=true;
                  }else{
                    return msg=false;
                  }
           }
      }
    })

    //验证用户密码
    $(document).on('blur','#password',function(){
      var password = $('#password').val();
      var passwords = /^\w{8,16}$/
      if (!passwords.test(password)) {
           $('#s_password').html("<font color='red'>密码必须8到16位</font>");
           msg1 = false;
      }else{
         $('#s_password').html("<font color='green'>√</font>");
         msg1 = true;
      }
    })

    //验证用户密码
    $(document).on('blur','#password1',function(){
      var password1 = $('#password1').val();
      var password = $('#password').val();

      if (password1 == password) {
         $('#s_password1').html("<font color='green'></font>");
         msg5 = true;
      }else{
        $('#s_password1').html("<font color='red'>密码不相同</font>");
           msg5 = false;
      }
    })

    //验证手机号不能为空，且达到需求
     $(document).on('blur','#tell',function(){
      var tell=$("#tell").val();
      if (tell=="") {
        $("#s_tell").html("<font color='red'>手机号不能为空</font>");
        return msg2=false;
      }else{ 
                // var user_name=;
                if (!/^1(52|56|76|82)\d{8}$/.test(tell)) {
                $("#s_tell").html("<font color='red'>手机号必须以152,156,176开头且11位</font>");
        return msg2=false;
                }else{
                  $.ajax({
                    url:'{:url("regist_once_tell")}',
                    data:{tell,tell},
                    type:"post",
                    dataType:"json",
                    success:function(res){
                      // alert(msg)
                           if (res==3) {
                             $("#s_tell").html("<font color='black'>√</font>");
                             var a=1;
                           }else{
                             $("#s_tell").html("<font color='red'>手机号已存在</font>");
                             var a=2;
                        }
                    }
                  })
                  if (a =1) {
                    return msg2=true;
                  }else{
                    return msg2=false;
                  }
                }
      }
    })

    //验证邮箱不能为空，且达到需求
    $(document).on('blur','#email',function(){
      var email=$("#email").val();
      if (email=="") {
        $("#s_email").html("<font color='red'>邮箱不能为空</font>");
        return msg3=false;
      }else{ 
                if (!/^\w+@\w+\.+(com|net|cn)$/.test(email)) {
                $("#s_email").html("<font color='red'>邮箱格式必须以.com .net  .cn结尾</font>");
                return msg3=false;
                }else{
                  $.ajax({
                    url:'{:url("regist_once_email")}',
                    data:{email,email},
                    type:"post",
                    dataType:"json",
                    success:function(res){
                           if (res==3) {
                             $("#s_email").html("<font color='black'>√</font>");
                             var aa=1;
                           }else{
                             $("#s_email").html("<font color='red'>邮箱已存在</font>");
                             var aa=2;
                           }
                    }
                  })
                  if (aa =1) {
                    return msg3=true;
                  }else{
                    return msg3=false;
                  }
             }
      }
    })

    //验证身份证号不能为空，且达到需求
    $(document).on('blur','#number',function(){
        var number = $('#number').val();
        var numbers = /^(\d{18}|\d{17}x)$/
        if (!numbers.test(number)) {
             $('#s_number').html("<font color='red'>身份证号不能为空,必须是18位数字或者17位数字加x</font>");
             msg4 = false;
        }else{
           $('#s_number').html("<font color='green'>√</font>");
           msg4 = true;
        }
    })

    //接收传来的结果，都是true的时候才能狗提交表单，否则有个是false的就不准提交
    $(document).on('click','#submit',function(){
      if (msg&&msg1&&msg2&&msg3&&msg4&&msg5) {
        $("#submit").submit();
      }else{
        alert('信息不完善')
        return false;
      }
    })
</script>
</html>
